<?php
/*
 * SiteMap生成Base类
 *  $dataArr[] = array(
                    'loc'         => $url,
                    'lastmod'     => $lastmoddt,
                    'changefreq'  => 'daily',
                    'priority'    => '0.8',

            );
 * $sitemapObj->createContent($dataArr,$filePath);
 */
class Libs_SiteMap_Base{

	protected $head;         //一个文件头
	protected $footer;       //一个文件底部


    function createContent(&$dataArr,$filePath,$gizp=false){
        $filestr = $this->head . $this->createSection($dataArr) . $this->footer;
        $this->writeFile($filestr,$filePath,$gizp);

    }
	function writeFile($content,$filename,$gizp){

		$handler = @fopen($filename,"w");
		if($handler){
    		fputs($handler,$content);
    		fclose($handler);
    		if($gizp) system ("gzip -f {$filename}");//gzip压缩
    		if($gizp) chmod($filename.'.gz',0777);
    		else chmod($filename,0777);
		}else{
		    echo "$filename 出错！权限问题";
		}
	}
}


?>
